package com.sgl.blog.service.impl;

import com.sgl.blog.mapper.LabelMapper;
import com.sgl.blog.pojo.BlogLabel;
import com.sgl.blog.service.LabelService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * @标题： TypeService
 * @内容：
 * @作者： 宋志豪
 */
@Service
public class LabelServiceImpl implements LabelService {


    @Resource
    private LabelMapper labelMapper;

    @Override
    public List<BlogLabel> findAll() {
        return labelMapper.selectAll();
    }

    @Override
    public List<BlogLabel> findByBaseId(Integer baseId) {
        return null;
    }

    @Override
    public BlogLabel findById(Integer id) {
        return labelMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<BlogLabel> findByStringId(String ids) {
        List<BlogLabel> blogLabels = new ArrayList<>();
        String[] idList = ids.split(",");
        for (String  i: idList) {
            int id = Integer.parseInt(i);
            blogLabels.add(findById(id));
        }
        return blogLabels;
    }


}
